import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import 'font-awesome/css/font-awesome.min.css'
import Vant from 'vant'
import 'vant/lib/index.css'
// vue中的粘贴板插件
import VueClipboard from 'vue-clipboard2'
// 使用vue中的插件
Vue.use(VueClipboard)
Vue.use(ElementUI, { size: 'small', zIndex: 3000 })
Vue.use(Vant)
// 去掉提示
Vue.config.productionTip = false
// 给vue的原型对象上添加属性和方法
Vue.prototype.levelName = ['普通会员', '专业会员', '', '企业会员', '定制会员']
// 时间处理函数
Vue.prototype.formatDate = function (time) {
  let date = new Date(time * 1000)
  let Y = date.getFullYear() + '-'
  let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-'
  let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' '
  let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':'
  let m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':'
  let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  return Y + M + D + h + m + s
}

Vue.prototype.getRemoteName = function (file, type) {
  if (!type) type = 'image'
  var sub = file.name.substr(file.name.lastIndexOf('.'))
  var date = new Date()
  var y = date.getFullYear()
  var m = date.getMonth() + 1
  m = m > 9 ? m : '0' + m
  var d = date.getDate() > 9 ? date.getDate() : '0' + date.getDate()
  var n = parseInt(Math.random() * 10000000)
  return type + '/' + y + m + d + '_' + this.userInfo.referral + '_' + n + sub
}
// 设置标题
Vue.prototype.setTitle = function (title) {
  document.title = title + '_筋斗云投票免费第三方微信投票活动制作平台'
}
// 路由守卫
router.afterEach((to, from) => {
  if (to.fullPath && _hmt) {
    _hmt.push(['_trackPageview', to.fullPath])
  }
})
// 创建vue并挂载app
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
